#include<bits/stdc++.h>
using namespace std;
#define int long long

string s[100005];

signed main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> s[i];
	string t;
	cin >> t;

	priority_queue<string, vector<string>, greater<string>> q;
	for (auto i : s) {
		if (i.find(t) == 0)
			q.push(i);
	}

	while (!q.empty()) {
		cout << q.top() << endl;
		q.pop();
	}
	return 0;
}
